#ifndef JSERVICEMANAGER_H
#define JSERVICEMANAGER_H

#if 0 //以淘汰：被元系统取代

#include <JXQCore/JXQGlobal>
#include <JXQCore/JVariant>
#include <functional>
#include <future>

namespace JXQ
{

class JConcurrent;
class JServiceManagerPrivate;

// 服务（过程）管理器
class JXQLIB_EXPORT JServiceManager
{
public:
	explicit JServiceManager();
	~JServiceManager();

public: // 注册服务
	using ServiceFunc = std::function<JVariant(JVariant)>;
	static bool registerService(const JString &serviceName, ServiceFunc &func);
	static bool registerService(const JString &serviceName, ServiceFunc &&func);
	static bool unregisterService(const JString &serviceName);

public: // 调用服务
	static std::future<JVariant> call(const JString &serviceName, const JVariant &arg);

	using CallBack = std::function<void(const JVariant&)>;

	std::future<JVariant> call(const JString &serviceName, const JVariant &arg,
								 CallBack &callBack);
	std::future<JVariant> call(const JString &serviceName, const JVariant &arg,
								 CallBack &&callBack);

	static JVariant callBlock(const JString &serviceName, const JVariant &arg);

public: // 调用服务
	inline std::future<JVariant> operator()(const JString &serviceName,
											const JVariant &arg);

	inline std::future<JVariant> operator()(const JString &serviceName,
											const JVariant &arg, CallBack &callBack);
	inline std::future<JVariant> operator()(const JString &serviceName,
											const JVariant &arg, CallBack &&callBack);

public: // other
	static int number();
	static bool isEmpty();
	static bool exists(const JString &serviceName);

private:
	J_DISABLE_COPY(JServiceManager)
	JServiceManagerPrivate *d_ptr;
};

inline std::future<JVariant> JServiceManager::
operator()(const JString &serviceName, const JVariant &arg)
{ return call(serviceName, arg); }

inline std::future<JVariant> JServiceManager::
operator()(const JString &serviceName, const JVariant &arg, CallBack &callBack)
{ return call(serviceName, arg, callBack); }

inline std::future<JVariant> JServiceManager::
operator()(const JString &serviceName, const JVariant &arg, CallBack &&callBack)
{ return call(serviceName, arg, callBack); }

} //namespace JXQ
#else
# waring "Obsolete: replaced by 'Meta System'"
#endif //以淘汰：被元系统取代

#endif // JSERVICEMANAGER_H
